home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
comm
/
term
/
term34Source.lha
/
termBeep.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-16
|
2KB
|
91 lines
/*
** termBeep.c
**
** Simple beep sound support routine
**
** Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
/* Beep():
*
* Produce a simple decent beep sound.
*/
VOID
Beep()
{
struct MsgPort *AudioPort;
/* Create the IO reply port. */
if(AudioPort = (struct MsgPort *)CreateMsgPort())
{
struct IOAudio *AudioRequest;
/* Create the audio IO info. */
if(AudioRequest = (struct IOAudio *)CreateIORequest(AudioPort,sizeof(struct IOAudio)))
{
STATIC UBYTE AnyChannel[] =
{
LEFT0F,LEFT1F, RIGHT0F,RIGHT1F
};
AudioRequest -> ioa_Request . io_Command = ADCMD_ALLOCATE;
AudioRequest -> ioa_Request . io_Flags = ADIOF_NOWAIT | ADIOF_PERVOL;
AudioRequest -> ioa_Request . io_Message . mn_Node . ln_Pri = 80;
AudioRequest -> ioa_Data = AnyChannel;
AudioRequest -> ioa_Length = sizeof(AnyChannel);
/* Open audio.device */
if(!OpenDevice(AUDIONAME,0,AudioRequest,0))
{
/* Minimal sine wave. */
STATIC BYTE __chip SineWave[] =
{
90,
127,
90,
0,
-90,
-127,
-90,
0
};
/* Prepare to play a beep sound. */
AudioRequest -> ioa_Request . io_Command = CMD_WRITE;
AudioRequest -> ioa_Request . io_Flags = ADIOF_PERVOL;
AudioRequest -> ioa_Period = SysBase -> ex_EClockFrequency / 3200;
AudioRequest -> ioa_Volume = 64 / 2;
AudioRequest -> ioa_Cycles = 150;
AudioRequest -> ioa_Data = SineWave;
AudioRequest -> ioa_Length = sizeof(SineWave);
/* Play it. */
BeginIO(AudioRequest);
WaitIO(AudioRequest);
/* Close audio.device */
CloseDevice(AudioRequest);
}
/* Free the audio request. */
DeleteIORequest(AudioRequest);
}
/* Free the IO reply port. */
DeleteMsgPort(AudioPort);
}
}